package com.zs.usc.common;

import lombok.*;
import lombok.experimental.Accessors;

/**
 * @author Zero
 * @description 业务异常
 * @date 2021/11/12 10:33
 */

@AllArgsConstructor
@ToString
@NoArgsConstructor
@Data
@Accessors(chain = true)
@Builder
public class BusinessException extends RuntimeException {
    // 错误代码
    private Integer errorCode = RestCode.ERROR_BUSINESS_COMMON.getCode();


    /**
     * 构造函数
     * @param message
     * @param cause
     */
    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * 构造函数
     * @param message
     */
    public BusinessException(String message) {
        super(message);
    }

    /**
     * 构造函数
     * @param errorCode
     * @param message
     * @param cause
     */
    public BusinessException(int errorCode, String message, Throwable cause) {
        super(message, cause);

        this.errorCode = errorCode;
    }

    /**
     * 构造函数
     * @param errorCode
     * @param message
     */
    public BusinessException(int errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    /**
     * 构造函数
     * @param responseStatus 响应状态枚举
     */
    public BusinessException(RestCode responseStatus){
        this(responseStatus, responseStatus.getMessage());
    }



    /**
     * 构造函数
     * @param responseStatus 响应状态枚举
     */
    public BusinessException(RestCode responseStatus,String msg){
        super(msg);
        this.errorCode = responseStatus.getCode();
    }

    /**
     * 构造函数
     * @param cause
     */
    public BusinessException(Throwable cause) {
        super(cause);
    }
}
